﻿@using Portal.Extensions
@{
    Layout = "~/Views/Shared/_MainLayout.cshtml";
    ViewBag.Title = "Job配置";
}
@model JobCommon.Model.Job_Config
<style>
    .help {
        color: red;
    }
</style>
<div class="panel panel-primary">
    <div class="panel-heading">
        <span class="panel-title">@ViewBag.Title</span>
        <span class="actions">
            <a href="/CronJobs/Delete?id=@Model.ID" id="btn_delete" class="btn red @ViewBag.IsDeleteHidden" data-toggle="modal" onclick="return confirm('确认删除该记录吗？')">删除</a>
            <a href="@Url.Action("Index")" class="btn grey">返回</a>
        </span>

        <span>
            @using (Html.BeginForm("Delete", "CronJobs", FormMethod.Post, new { id = "frm_delete" }))
            {
                @Html.HiddenFor(model => model.ID, new { name = "id" })
            }
        </span>

    </div>
    <div class="panel-body container-fluid">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @using (Html.BeginForm("Edit", "CronJobs", FormMethod.Post, new { id = "form_jobconfig", enctype = "multipart/form-data", @class = "horizontal-form form-inline" }))
        {
            <div>
                @Html.HiddenFor(model => model.ID)
                @Html.HiddenFor(model => model.DataChange_CreateTime)
            </div>

            <div class="row">
                @Html.LabelFor(model => model.JobName, htmlAttributes: new { @class = "control-label col-md-2 textStyle" })
                @if (ViewBag.IsEdit != null && ViewBag.IsEdit)
                {
                    <div class="textStyle col-md-4">
                        @Model.JobName
                    </div>
                }
                else
                {
                    <div class="controls  col-md-4">
                        @Html.TextBoxFor(model => model.JobName, new { @class = " col-md-12" })
                        @Html.ValidationMessageFor(model => model.JobName, "", new { @class = "help col-md-12" })
                    </div>
                }

                @Html.LabelFor(model => model.JobDisplayName, htmlAttributes: new { @class = "control-label col-md-2 textStyle" })
                <div class="controls col-md-4">
                    @Html.TextBoxFor(model => model.JobDisplayName, new { @class = "col-md-12", @aa = "aaa" })

                    @Html.ValidationMessageFor(model => model.JobDisplayName, "", new { @class = "help col-md-12" })
                </div>
            </div>


            <div class="row">
                @Html.LabelFor(model => model.StartTime, htmlAttributes: new { @class = "control-label  col-md-2" })
                <div class="controls col-md-4">
                    @Html.TextBoxFor(model => model.StartTime, "", new { @class = " col-md-12" })
                    @Html.ValidationMessageFor(model => model.StartTime, "", new { @class = "help col-md-12" })
                </div>

                @*@Html.LabelFor(model => model.StartTime, htmlAttributes: new { @class = "control-label  col-md-2" })
                    <div class="controls col-md-4">
                        @Html.TextBoxFor(model => model.StartTime,"",new { @class = "help col-md-8" })
                    </div>
                    @Html.ValidationMessageFor(model => model.StartTime, "", new { @class = "help" })*@

            </div>

            <div class="row">
                @Html.LabelFor(model => model.RepeatMode, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="controls col-md-4">
                    @(Html.EnumToDropdownList((JobCommon.Model.RepeatModeEnum)Model.RepeatMode, "RepeatMode", "col-md-8", "--请选择--"))
                </div>

            </div>

            <div class="row" id="FixedExpressionRow" style="@(Model.RepeatMode != (int)JobCommon.Model.RepeatModeEnum.Interval?"block":"display:none")">
                @Html.LabelFor(model => model.FixedExpression, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="controls col-md-10">
                    @Html.TextAreaFor(model => model.FixedExpression, new { @class = "col-md-12" })
                </div>

            </div>

            <div class="row" id="IntervalRow" style="@(Model.RepeatMode == (int)JobCommon.Model.RepeatModeEnum.Interval?"block":"display:none")">
                @Html.LabelFor(model => model.CycleUnit, htmlAttributes: new { @class = "control-label col-md-2 " })
                <div class="controls col-md-4">
                    @(Html.EnumToDropdownList((JobCommon.Model.CycleUnitEnum)Model.CycleUnit, "CycleUnit", "col-md-8", "--请选择--"))
                    @*@Html.DropDownListFor(model => model.CycleUnit, (List<SelectListItem>)ViewBag.CycleUnits, "--请选择--")*@
                </div>

                @Html.LabelFor(model => model.Interval, htmlAttributes: new { @class = "control-label col-md-2 " })
                <div class="controls col-md-4">
                    @Html.TextBoxFor(model => model.Interval, "", new { @class = "control-label col-md-12 " })
                </div>
                @Html.ValidationMessageFor(model => model.Interval, "", new { @class = "help col-md-12" })

            </div>


            <div class="row">
                <label class="control-label col-md-2 textStyle" for="assemblyFile">请上传job所在的dll</label>
                <div class="controls col-md-6">
                    <input type="file" name="assemblyFile" class="span12" id="fileAttachment" accept=".dll" />

                </div>
                <div class="controls col-md-4">
                    <input type="submit" name="buttons" class="span12" id="upload" value="上传" />
                </div>
            </div>

            <div class="row">
                @Html.LabelFor(model => model.FilePath, htmlAttributes: new { @class = "control-label col-md-2 span2" })
                <div class="controls col-md-10">
                    @Html.TextBoxFor(model => model.FilePath, "", new { @class = "m-wrap col-md-12", @readonly = "readonly" })
                    @Html.ValidationMessageFor(model => model.FilePath, "", new { @class = "help col-md-12" })
                </div>
            </div>

            <div class="row">
                @Html.LabelFor(model => model.ClassName, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="controls col-md-4">
                    @Html.TextBoxFor(model => model.ClassName, "", new { @class = "m-wrap col-md-12" })
                    @Html.ValidationMessageFor(model => model.ClassName, "", new { @class = "help col-md-12" })
                </div>

                @Html.LabelFor(model => model.IsEnable, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class=" controls col-md-4">
                    @Html.EditorFor(model => model.IsEnable, new { htmlAttributes = new { @class = "col-md-12 form-control" } })
                </div>
            </div>

            <div class="row">
                <div class="col-md-2">

                </div>
                <div class="form-actions col-md-2">
                    <button type="submit" class="btn green" name="buttons" value="btnSave"><i class="icon-ok"></i> 保存</button>
                </div>
            </div>

        }

    </div>
</div>

<script>
    $(function () {

        $("#RepeatMode").change(function () {
            var mode = $(this).val();
            if (mode == 2) {
                $("#IntervalRow").show();
                $("#FixedExpressionRow").hide();
            } else {
                $("#IntervalRow").hide();
                $("#FixedExpressionRow").show();
            }
        });
    });
</script>
